Be more sensitive to losing sync with platform timer.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 7 Sep 2005 10:04:54 +0000 (10:04 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 7 Sep 2005 10:04:54 +0000 (10:04 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/time.c

index 81100e7a1cf9c1c274470950e173a16db75d290c..7e972bea9457d18137aa33a5c5c6a6e6991ac67a 100644 (file)
@@ -791,6 +791,13 @@ static void local_time_calibration(void *unused)
     stime_elapsed64 = curr_master_stime - prev_master_stime;
     tsc_elapsed64   = curr_tsc - prev_tsc;
 
+    /*
+     * Weirdness can happen if we lose sync with the platform timer.
+     * We could be smarter here: resync platform timer with local timer?
+     */
+    if ( ((s64)stime_elapsed64 < (EPOCH / 2)) )
+        goto out;
+
     /*
      * Calculate error-correction factor. This only slows down a fast local
      * clock (slow clocks are warped forwards). The scale factor is clamped
@@ -854,6 +861,7 @@ static void local_time_calibration(void *unused)
     cpu_time[cpu].stime_local_stamp  = curr_local_stime;
     cpu_time[cpu].stime_master_stamp = curr_master_stime;
 
+ out:
     set_ac_timer(&cpu_time[cpu].calibration_timer, NOW() + EPOCH);
 
     if ( cpu == 0 )